package forwardredirect;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/red")
public class RedirectServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 给请求添加属性
		req.setAttribute("name", "zhangsan");
		// 重定向: 路径前面不能加/，必须是向前项目的相对路径
		resp.sendRedirect("a");
//		resp.sendRedirect("http://www.baidu.com");
	}
}
